Function: pcase--expand-`
pcase--expand-` is a byte-compiled function defined in pcase.el.gz.
Signature
(pcase--expand-\` QPAT)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/pcase.el.gz
(defun pcase--expand-\` (qpat)
(cond
((eq (car-safe qpat) '\,) (cadr qpat))
((or (eq (car-safe qpat) '\,@) (eq qpat '...))
(error "Unsupported QPAT: %S" qpat))
((vectorp qpat)
(let* ((trivial t)
(contents nil)
(upats nil))
(dotimes (i (length qpat))
(let* ((upat (pcase--expand-\` (aref qpat i))))
(if (eq (car-safe upat) 'quote)
(push (cadr upat) contents)
(setq trivial nil))
(push `(app (aref _ ,i) ,upat) upats)))
(if trivial
`',(apply #'vector (nreverse contents))
`(and (pred vectorp)
(app length ,(length qpat))
,@(nreverse upats)))))
((consp qpat)
(let ((upata (pcase--expand-\` (car qpat)))
(upatd (pcase--expand-\` (cdr qpat))))
(if (and (eq (car-safe upata) 'quote) (eq (car-safe upatd) 'quote))
`'(,(cadr upata) . ,(cadr upatd))
`(and (pred consp)
(app car-safe ,upata)
(app cdr-safe ,upatd)
,@(when (eq (car qpat) '\`)
`((guard ,(macroexp-warn-and-return
"Nested ` are not supported in Pcase patterns"
t nil nil qpat))))))))
((or (stringp qpat) (numberp qpat) (symbolp qpat)) `',qpat)
;; In all other cases just raise an error so we can't break
;; backward compatibility when adding \` support for other
;; compounded values that are not `consp'
(t (error "Unknown QPAT: %S" qpat))))